<?php
/**
 * Author:Arthur
 * Date:2013-2-20
 * File Name:addReply.php
 * Email:kingarthurx@sina.cn
 */
 require ('../include/init.php');
/**
 * 八优后台推送URL
 *http://sms.maszy.cn/api/addReply.php?clientid={0}&msg={1}&mobile={2}&receivetime={3}&destmobile={4}&msg_type=1
 * 获取八优后台推送参数
 */

$method = $_GET['method'];
global $view_file;
	
if (empty($method)) {
	$method = 'select';
}
if ($method === 'select') {
		getServerReply();
}

/**
 * 获取八优服务器推送回复短信内容,并插入到本地数据库中。
 */
function getServerReply(){
	$reply = new Reply();
	$replyArr = $reply->getUserApi();
	
	$clientid=$_REQUEST['clientid'];
	$msg=$_REQUEST['msg'];
	$mobile = $_REQUEST['mobile'];
	$receivetime = $_REQUEST['receivetime'];
	$destmobile = $_REQUEST['destmobile'];
	$msg_type = $_REQUEST['msg_type'];
	
	$reply->company_id = $_SESSION['user']['customer']->company_id;
	$reply->clientid = $clientid;
	$reply->mobile = $mobile;
	$reply->destmobile = $destmobile;
	$reply->content = $msg;
	$reply->time = $receivetime;
	$reply->msg_type = $msg_type;
	/**
	 * 获取的回复内容插入到本地数据库
	 */
	$reply ->insertReply();
	
}
